// AdminUserStatisticsController.java
package com.scuec.groupfive.Controller;

import com.scuec.groupfive.service.AdminStatisticsService;
import com.scuec.groupfive.vo.AdminUserStatisticsVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/admin/statistics")
public class AdminUserStatisticsController {

    private final AdminStatisticsService adminStatisticsService;

    @Autowired
    public AdminUserStatisticsController(AdminStatisticsService adminStatisticsService) {
        this.adminStatisticsService = adminStatisticsService;
    }

    @GetMapping("/user/{userId}")
    public ResponseEntity<AdminUserStatisticsVO> getUserStatistics(@PathVariable Long userId) {
        AdminUserStatisticsVO statistics = adminStatisticsService.getUserStatistics(userId);
        if (statistics != null) {
            return ResponseEntity.ok(statistics);
        } else {
            return ResponseEntity.notFound().build();
        }
    }
}